SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO

CREATE VIEW [SSB].[rollupByFund_FSType_Date] AS


SELECT pid.ART_FundID AS FundId, ft.FSType, SUM(dm.ReportDateNetAmount) AS SumReportDateAmt, dm.PeriodEndDate AS [Date] FROM ssb.DailyIncome_Dump dm
INNER JOIN ssb.IncomeType it ON it.AccountName = dm.AccountName
INNER JOIN  SSB.FSIncomeType ft ON ft.FSIncomeTypeId = it.FSIncomeTypeId
INNER JOIN  ssb.LocalCurrencyCode lc ON lc.LocalCurrencyCodeid = it.LocalCurrencyCodeId
INNER JOIN  dbo.mapSSB_PortID pid ON dm.Fund = pid.SSB_PortfolioID 
AND dm.LocalCurrencyCode = lc.LocalCurrencyCode
GROUP BY pid.ART_FundID, ft.FSType, dm.PeriodEndDate


GO
